package player
{
	import flash.display.Sprite;
	
	import geometry.IGeobject;
	
	public class GeobjectView
	{
		// --------------------------------------------------------------------------------------------
		// Public memebers


		// --------------------------------------------------------------------------------------------
		public function GeobjectView(obj : IGeobject)
		{
			_object = obj;
			_sprite = new Sprite();
			drawSprite();
		}
		
		// --------------------------------------------------------------------------------------------
		public function get sprite(): Sprite{
			return _sprite;
		}

		// --------------------------------------------------------------------------------------------
		public function get geobject(): IGeobject{
			return _object;
		}

		// --------------------------------------------------------------------------------------------
		public function setLineStyle(thickness : int, color : Number): void{
			
			_lineThickness = thickness;
			_lineColor = color;
			drawSprite();
		}	  
		
		// --------------------------------------------------------------------------------------------
		private function drawSprite():void{

			_sprite.graphics.clear();
			_sprite.graphics.lineStyle(_lineThickness, _lineColor);
			if(_object.points.length > 1){
	    	_sprite.graphics.moveTo(_object.points[0].x, _object.points[0].y);
	    	for(var i:int = 1; i < _object.points.length; i++) {
	    		_sprite.graphics.lineTo(_object.points[i].x, _object.points[i].y);
	    	}
	  	}
		}


		// --------------------------------------------------------------------------------------------
		// Private members
		private var _object : IGeobject
		private var _sprite : Sprite;
		private var _lineColor:Number = 0x000000;
		private var _lineThickness:int = 3;
	}
}